package LifeTest;

public class FindJudge {

	public static void main(String[] args) {
		int[][] trust = {{1,2},{2,3}};
		int n = 3;
		int res = new FindJudge().findJudge(n, trust);
		System.out.println(res);
	}
	
 public int findJudge(int n, int[][] trust) {
	 	int[][] num = new int[n+1][2];
        for(int i = 0;i < trust.length;i ++){
            num[trust[i][0]][0] = 1;
            num[trust[i][1]][1] += 1;
        }
        for (int i = 1; i < num.length; i++) {
			if(num[i][0] == 0 && num[i][1] == n - 1)
				return i;
		}
		return -1;
 	}
}
